############# ModelViewSet编写接口 ###################

# from django.urls import path, include
# from rest_framework.routers import DefaultRouter
# from .views import StudentViewSet
#
# router = DefaultRouter()
# router.register(r'students', StudentViewSet, basename='student')  # 注册视图集
#
# urlpatterns = [
#     path('', include(router.urls)),  # 包含自动生成的路由
# ]


############# APIView编写视图接口 ###################

from django.urls import path
from .views import StudentListAPIView, StudentDetailAPIView

urlpatterns = [
    # 学生列表get和创建post
    path('students/', StudentListAPIView.as_view(), name='student-list'),

    # 学生详情get、更新put/patch、删除delete
    path('students/<int:pk>/', StudentDetailAPIView.as_view(), name='student-detail'),
]

